---- _____  _____   _____ _____  __  __ ----
----|  __ \|  __ \ / ____|  __ \|  \/  |----
----| |__) | |__) | |  __| |  | | \  / |----
----|  _  /|  ___/| | |_ | |  | | |\/| |----
----| | \ \| |    | |__| | |__| | |  | |----
----|_|  \_\_|     \_____|_____/|_|  |_|----
--------------------------------------------
----Code relating to shared interactions----
--------------------------------------------
AddCSLuaFile()

if SERVER then
	util.AddNetworkString( "GetEntityInteract" )
	util.AddNetworkString( "SetEntityInteract" )
	
	net.Receive("GetEntityInteract", function(len, ply) --Get the information we need to interact with the entity.
		local ent = net.ReadEntity()
		local interact = {}
		if(ent.Vendor)then
			interact[1] = "vendor" 
		elseif(ent:GetClass() == "rpgdm_interactable")then
			local itype = ent.Type
			if(itype == OBJ_INTERACT)then
				print("Interact")
			elseif(itype == OBJ_INTERACTQUEST)then
				print("InteractQuest")
			elseif(itype == OBJ_LOOTQUEST)then
				print("LootQuest")
			elseif(itype == OBJ_LOOT)then
				print("Loot")
			elseif(itype == OBJ_GAMEOBJECTIVE)then
				print("GameObjective")
			end
		else
			ent:EmitSound("Sandbawgs/weapons/weapon_slowrocket/rocket_bounce.wav", 140, 100+math.random(-40,40))
		end
		net.Start("SetEntityInteract")
		net.WriteTable(interact)
		net.Send(ply)
	end)
end

if CLIENT then
	net.Receive("SetEntityInteract", function(len, ply) --Set interaction of the entity clientside.
		tbl = net.ReadTable()
		if(tbl[1] == "vendor")then
			if(!MenuOpen)then
				ShowPresetWindow()
			end
		end
	end)
end
